package com.chwn.curiousdiary.api;

import com.chwn.curiousdiary.bean.BannerBean;
import com.chwn.curiousdiary.bean.HotSearchBean;
import com.chwn.curiousdiary.bean.StoryBean;
import com.chwn.curiousdiary.bean.StoryCountBean;
import com.chwn.curiousdiary.bean.StoryListBean;
import com.chwn.curiousdiary.bean.StoryTypeBean;
import com.chwn.harulib.mvp.rx.HttpResult;

import java.util.List;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Myshikin on 2017/3/20.
 */

public interface IHomeApi {
    /**
     * 获取轮播图
     * 标识 Android&iOS	osType	number	(1 Android 2 iOS)
     * @return
     */
    /*@FormUrlEncoded
    @POST("app/home/getBannerList.action")
    Observable<HttpResult<List<BannerBean>>> getBannerList(
            @Field("osType") int osType
    );*/
    @GET("app/home/getBannerList.action")
    Observable<HttpResult<List<BannerBean>>> getBannerList(
            @Query("osType") int osType
    );

    /**
     * 注意：
     * 根据分类获取故事数据 缺少参数 修改为获取故事集接口
     * 故事类型	storyType	number
     * 获取条数	pageRecords	number
     * 当前页码	nowPage	number
     * 标识 Android&iOS	osType	number	(1 Android 2 iOS)
     * @return
     */
    /*@FormUrlEncoded
    @POST("app/home/getStoryTypeList.action")
    Observable<HttpResult<List<StoryBean>>> getStoryTypeList(
            @Field("storyType") int storyType,
            @Field("pageRecords") int pageRecords,
            @Field("nowPage") int nowPage,
            @Field("osType") int osType,
            @Field("babysex") int babysex,
            @Field("babybirth") String babybirth
    );*/
    @GET("app/home/getStoryTypeList.action")
    Observable<HttpResult<List<StoryListBean>>> getStoryTypeList(
            @Query("storyType") String storyType,
            @Query("userToken") String userToken,
            @Query("pageRecords") int pageRecords,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType
    );
    //            @Query("babysex") int babysex,
    //            @Query("babybirth") String babybirth


    /**
     * 最新故事数据
     * 当前页码	nowPage	number
     * 标识 Android&iOS	osType	number	(1 Android 2 iOS)
     * 获取条数	pageRecords	number
     * @return
     */
  /*  @FormUrlEncoded
    @POST("app/newest/getNewestList.action")
    Observable<HttpResult<List<StoryBean>>> getNewestStoryList(
            @Field("pageRecords") int pageRecords,
            @Field("nowPage") int nowPage,
            @Field("osType") int osType
    );*/
    @GET("app/newest/getNewestList.action")
    Observable<HttpResult<List<StoryListBean>>> getNewestStoryList(
            @Query("pageRecords") int pageRecords,
            @Query("userToken") String userToken,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType
    );


    /**
     * 首页猜你喜欢数据
     * 当前页码	nowPage	number
     * 标识 Android&iOS	osType	number	(1 Android 2 iOS)
     * 获取条数	pageRecords	number
     * @return
     */
    /*@FormUrlEncoded
    @POST("app/home/getHomeList.action")
    Observable<HttpResult<List<StoryBean>>> getHomeList(
            @Field("pageRecords") int pageRecords,
            @Field("nowPage") int nowPage,
            @Field("osType") int osType,
            @Field("babysex") int babysex,
            @Field("babybirth") String babybirth
    );*/
    @GET("app/home/getHomeList.action")
    Observable<HttpResult<List<StoryListBean>>> getHomeList(
            @Query("pageRecords") int pageRecords,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType,
            @Query("babysex") int babysex,
            @Query("babybirth") String babybirth
    );

    @GET("app/home/getHomeList.action")
    Observable<HttpResult<List<StoryListBean>>> getHomeList(
            @Query("pageRecords") int pageRecords,
            @Query("userToken") String userToken,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType
    );

    /**
     * 根据故事包ID获取故事包中数据
     * pageRecords	number
     * storyPackageId	string	故事包id
     * osType	number	(1 Android 2 iOS)
     * nowPage	number
     * @return
     */
    @GET("app/home/getStoryList.action")
    Observable<HttpResult<List<StoryBean>>> getStoryList(
            @Query("storyPackageId") String storyPackageId,
            @Query("userToken") String userToken,
            @Query("pageRecords") int pageRecords,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType
    );

    /**
     * 获取首页的故事分类
     * @param pageRecords
     * @param nowPage
     * @param osType
     * @param storyType
     * @return
     */
    /*@FormUrlEncoded
    @POST("app/home/findStoryClassifyList.action")
    Observable<HttpResult<List<StoryTypeBean>>> getStoryClassifyList(
            @Field("pageRecords") int pageRecords,
            @Field("nowPage") int nowPage,
            @Field("osType") int osType,
            @Field("storyType") String storyType
    );*/
    @GET("app/home/findStoryClassifyList.action")
    Observable<HttpResult<List<StoryTypeBean>>> getStoryClassifyList(
            @Query("pageRecords") int pageRecords,
            @Query("nowPage") int nowPage,
            @Query("osType") int osType,
            @Query("storyType") String storyType
    );

    @FormUrlEncoded
    @POST("app/story/getCollectedStoryList.action")
    Observable<HttpResult<List<StoryBean>>> getCollectionStoryList(
            @Field("pageType") String pageType,
            @Field("pageRecords") int pageRecords,
            @Field("nowPage") int nowPage,
            @Field("osType") int osType,
            @Field("userToken") String userToken
    );

    @FormUrlEncoded
    @POST("app/story/getStoryDetail.action")
    Observable<HttpResult<List<StoryBean>>> getStoryDetail(
            @Field("storyId") String storyId,
            @Field("userToken") String userToken,
            @Field("osType") int osType
    );

    /**
     * 故事分享成功后的统计
     * @param storyId
     * @param userToken
     * @param shareType
     * @return
     */
    @FormUrlEncoded
    @POST("app/story/shareStory.action")
    Observable<HttpResult<Object>> shareStory(
            @Field("storyId") String storyId,
            @Field("userToken") String userToken,
            @Field("shareType") int shareType
    );

    /**
     * 获取对应故事分类下故事总个数
     * @param storyPackageId
     * @param osType
     * @return
     */
    @FormUrlEncoded
    @POST("app/home/getStoryTypeCount.action")
    Observable<HttpResult<StoryCountBean>> getStoryTypeCount(
            @Field("storyPackageId") String storyPackageId,
            @Field("osType") int osType
    );

    /**
     * 用户收听故事统计
     * @param storyId
     * @param userToken
     * @param osType
     * @return
     */
    @FormUrlEncoded
    @POST("app/story/storyListenHistory.action")
    Observable<HttpResult<Object>> storyListenHistory(
            @Field("storyId") String storyId,
            @Field("userToken") String userToken,
            @Field("osType") int osType
    );

    /**
     * 获取热搜
     * @param osType
     * @return
     */
    @GET("app/story/getHotSearch.action")
    Observable<HttpResult<List<HotSearchBean>>> getHotSearch(
            @Query("osType") int osType
    );

    /**
     * 搜索列表
     * @param osType
     * @return
     */
    @FormUrlEncoded
    @POST("app/story/storySearch.action")
    Observable<HttpResult<List<StoryListBean>>> storySearch(
            @Field("searchKey") String searchKey,
            @Field("userToken") String userToken,
            @Field("nowPage") int nowPage,
            @Field("pageRecords") int pageRecords,
            @Field("osType") int osType
    );
}
